package com.xbongbong.pro.sheet.pojo.dto;

import com.xbongbong.pro.sheet.pojo.SheetAttrPojo;
import com.xbongbong.pro.sheet.pojo.SheetInfoPojo;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 删除/批量删除回/付款单，更新其关联业务（客户、合同、应收款，或者供应商、采购合同、付款计划）dto
 * @author zcp
 * @version v1.0
 * @since v1.0
 */
@Getter
@Setter
@ToString
public class SheetDeleteHandleRelateDTO implements Serializable {
    private static final long serialVersionUID = -2718446070648197705L;

    /**
     * 回款单/付款单的字段attr pojo
     */
    private SheetAttrPojo sheetAttrPojo;
    /**
     * 要删除的回款单编号（如果有删除失败的情况，则需要移除部分回款单编号）
     */
    private List<String> delNoList;
    /**
     * 回款单id-回款单信息pojo
     */
    private Map<Long, SheetInfoPojo> sheetInfoMap;
    /**
     * 客户id-客户要增加or减少的余额
     */
    private Map<Long, Double> customerIdToBalance;
    /**
     * 合同id-要增加or减少的已收（金额正负已处理）
     */
    private Map<Long, Double> contractIdToAmount;
    /**
     * 应收款id-要增加or减少的已收（金额正负已处理）
     */
    private Map<Long, Double> paymentIdToAmount;
    /**
     * 合同id-要增加or减少的未收（金额正负已处理）
     */
    private Map<Long, Double> contractIdToUnAmount;
    /**
     * 应收款id-要增加or减少的未收（金额正负已处理）
     */
    private Map<Long, Double> paymentIdToUnAmount;
    /**
     * 合同id-要增加or减少的坏账（金额正负已处理）
     */
    private Map<Long, Double> contractIdToBad;
    /**
     * 应收款id-要增加or减少的坏账（金额正负已处理）
     */
    private Map<Long, Double> paymentIdToBad;
    /**
     * 合同id集合
     */
    private Set<Long> contractIds;
    /**
     * 应收款id集合
     */
    private Set<Long> paymentIds;
    /**
     * 父子单据相同的uuid - 该uuid对应的父单及其所有子单
     */
    private Map<String, List<Long>> uuidSheetMap;
    /**
     * 合同id-该合同下的所有回款单id、编号集合（注意：不能单单用子回款单去构建关系map，因为父的回款单也要构建到关系内）
     */
    private Map<Long, List<Long>> cidSheetIdListMap;
    private Map<Long, List<String>> cidSheetNoListMap;
    /**
     * 应收款id-该应收款下的所有回款单id、编号集合（注意：不能单单用子回款单去构建关系map，因为父的回款单也要构建到关系内）
     */
    private Map<Long, List<Long>> pidSheetIdListMap;
    private Map<Long, List<String>> pidSheetNoListMap;

    public SheetDeleteHandleRelateDTO(int initialCapacity, SheetAttrPojo sheetAttrPojo, List<String> delNoList, Map<String, List<Long>> uuidSheetMap, Map<Long, List<Long>> cidSheetIdListMap, Map<Long, List<String>> cidSheetNoListMap, Map<Long, List<Long>> pidSheetIdListMap, Map<Long, List<String>> pidSheetNoListMap) {
        this.sheetAttrPojo = sheetAttrPojo;
        this.delNoList = delNoList;
        this.sheetInfoMap = new HashMap<>(initialCapacity);
        this.customerIdToBalance = new HashMap<>(initialCapacity);
        this.contractIdToAmount = new HashMap<>(initialCapacity);
        this.paymentIdToAmount = new HashMap<>(initialCapacity);
        this.contractIdToUnAmount = new HashMap<>(initialCapacity);
        this.paymentIdToUnAmount = new HashMap<>(initialCapacity);
        this.contractIdToBad = new HashMap<>(initialCapacity);
        this.paymentIdToBad = new HashMap<>(initialCapacity);
        this.contractIds = new HashSet<>();
        this.paymentIds = new HashSet<>();
        this.uuidSheetMap = uuidSheetMap;
        this.cidSheetIdListMap = cidSheetIdListMap;
        this.cidSheetNoListMap = cidSheetNoListMap;
        this.pidSheetIdListMap = pidSheetIdListMap;
        this.pidSheetNoListMap = pidSheetNoListMap;
    }
}
